<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入1-100之间的整数" id="i1">
<input type="button" value="猜一猜" onclick="f()">
<div id="d1">

</div>
<span>
  作弊
</span>
<script>

  let num = parseInt(Math.random()*100+1);
  let s = document.querySelector("span");
  s.innerText=num;
  let count = 0;
  function f(){
    /*let num =Math.random()*100+1;*/
    /*num = parseInt(num);*/

    count++;
    if (num>i1.value){
      d1.innerText="猜小了"

    }else if (num<i1.value){
      d1.innerText="猜大了"

    }else{

      d1.innerText="恭喜您,在第"+count+"次猜对啦"
    }

  }

</script>
</body>
</html>